package com.easylinkin.linkappapi.location.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.easylinkin.linkappapi.common.model.RequestModel;
import com.easylinkin.linkappapi.location.entity.LinkappLocationRecord;
import com.easylinkin.linkappapi.location.entity.dto.DeviceRecordQueryDTO;
import com.easylinkin.linkappapi.location.mapper.LinkappLocationRecordMapper;
import com.easylinkin.linkappapi.location.service.ILinkappLocationRecordService;
import com.easylinkin.linkappapi.security.context.LinkappUserContextProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import site.morn.rest.RestBuilders;
import site.morn.rest.RestMessage;

import java.util.List;

/**
 * 定位记录表 服务实现类
 *
 * @author JG
 * @since 2023-09-20
 */
@Service
public class LinkappLocationRecordServiceImpl extends ServiceImpl<LinkappLocationRecordMapper, LinkappLocationRecord> implements ILinkappLocationRecordService {

    @Autowired
    private LinkappUserContextProducer linkappUserContextProducer;

    /**
    * @Description: 定位记录分页查询
    * @Param: [requestModel]
    * @return: site.morn.rest.RestMessage
    * @Author: 胡明威
    * @Date: 2023/10/19
    */
    @Override
    public RestMessage queryLocationRecordList(RequestModel<DeviceRecordQueryDTO> requestModel) {
        requestModel.getCustomQueryParams().setTenantId(linkappUserContextProducer.getNotNullCurrent().getTenantId());
        List list = baseMapper.queryLocationRecordList(requestModel.getCustomQueryParams(), requestModel.getPage());
        requestModel.getPage().setRecords(list);
        return RestBuilders.successBuilder(requestModel.getPage()).build();
    }
}
